import React, {useEffect, useState} from 'react';
import {View, Text, TouchableOpacity, ScrollView} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import dayjs from 'dayjs';
import AreaView from '../../components/Layout/AreaView';
import styles from './style';
import {getEnrollList} from '../../service/my';

const MyApply = () => {
  const navigation = useNavigation();
  const [pn, setPn] = useState(1);
  const [list, setList] = useState([]);
  useEffect(() => {
    getEnrollList({pn, ps: 10000}).then((res) => {
      console.log(res);
      setList(res.rows);
    });
  }, [pn]);
  return (
    <AreaView>
      <ScrollView showsVerticalScrollIndicator={false} style={styles.container}>
        {(list || []).map((item, index) => (
          <TouchableOpacity
            key={index}
            onPress={() => {
              navigation.push('ApplyList', {
                erId: item.erId,
              });
            }}>
            <View style={styles.top}>
              <View style={styles.dot_container}>
                <View style={styles.dot} />
              </View>
              <Text style={styles.time}>
                {dayjs(item.erTime).format('YYYY-MM-DD HH:mm:ss')}
              </Text>
            </View>
            <View style={styles.bottom}>
              <View style={styles.line_container}>
                <View style={styles.line} />
              </View>
              <View style={styles.desc_container}>
                <Text style={styles.title}>{item.erTitle}</Text>
                <View style={styles.desc}>
                  <Text style={styles.desc_info}>
                    <Text style={styles.desc_title}>简介文字：</Text>
                    {item.artDesc}
                  </Text>
                  <Text style={styles.detail}>查看详情>>></Text>
                </View>
              </View>
            </View>
          </TouchableOpacity>
        ))}
      </ScrollView>
    </AreaView>
  );
};

export default MyApply;
